package jus.aoo.lisp;

public class Cons extends Subr implements ParamEvaluable {
	public static Cons CONS = new Cons();
	
	public Sexpr apply(Scons e) throws LispException{
		Sexpr a = e.car();
		Sexpr b = e.cdr();
		Sexpr c = b.cdr();
		
		if(c instanceof Nil){
			if(b.isListe()){
				return new Scons(a,b.car());
			}else{
				return new Scons(a,b);
			}
		}
		
		throw new LispException("Erreur Cons : too much parameters");
	}
	
	public String toString(){
		return "cons";
	}
	
}
